local spear = fk.CreateSkill {
  name = "spear",
}

Fk:loadTranslationTable{
  ["spear"] = "长矛",
  [":spear"] = "出牌阶段限一次，你可以弃置至少一张手牌并摸一张牌，令一名其他角色弃置一张与你弃置的牌花色均不同的牌，否则你对其造成1点伤害。",
  ["#spear"] = "长矛：你可以弃至少一张牌，令一名角色选择弃一张与此牌花色均不同的牌或你对其造成1点伤害",
  ["#spear-discard"] = "长矛：你需弃一张不同花色的牌，否则 %src 对你造成1点伤害！",
  ["$spear"] = "矛矛雨！",
}

spear:addEffect("active", {
  anim_type = "offensive",
  prompt = "#spear",
  min_card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(spear.name, Player.HistoryPhase) == 0 and not player:isKongcheng()
  end,
  card_filter = function(self, player, to_select, selected)
    return table.contains(player:getCardIds("h","e"), to_select) and not player:prohibitDiscard(to_select)
  end,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select.id ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local suits = {"heart", "spade", "club", "diamond"}
    for _, id in ipairs(effect.cards) do
      table.removeOne(suits, Fk:getCardById(id):getSuitString())
    end
    player:drawCards(1, spear.name)
    room:throwCard(effect.cards, spear.name, player, player)
    if target.dead then return end
    if #suits == 0 or #room:askToDiscard(target, {
      skill_name = spear.name,
      min_num = 1,
      max_num = 1,
      pattern = table.concat(suits, ","),
      prompt = "#spear-discard",
      cancelable = true,
    }) == 0 and not target.dead then
      room:damage{
        from = player,
        to = target,
        damage = 1,
        skillName = spear.name,
    }
    end
  end,
})

return spear
